New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[systeminfo] dynamic channels #13562
Conversation
Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
Looks like the integration tests are not working. |
Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
614d5d0
to
8ed6435
Compare
@lolodomo I noticed and tried understanding why. I have made some adjustments, which solved part of the issues. But I am left with 3 tests that consistently fail with no changes to the code for the functionality in these tests. The tests are very similar to many other tests that work without problem. I can't figure it out. Update: I now see that the Java 17 build ran through, but not the Java 11 build, failing on one test. It looks like the mocked object doesn't return the mock value consistently. |
Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
@lolodomo I found the problem with the CpuLoad1-5-15 update. It was introduced in the previous PR. I didn't notice as these channels are not available on Windows and I develop on Windows. Surprisingly, the integration tests did not fail with the previous PR, which is beyond my understanding. |
Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
Do you think you could have fixed #13524 ? |
It sure looks similar to what I saw. Let's hope it has that effect. I noticed the following line in the test setup code sometimes returned null, probably because the service was not registered in time. And this was not tested (there were no Null annotations and no assert).
I put an assert and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Partial review (remains to review the thing handler and the unit tests).
You renamed a channel type which breaks the compatibility with already created things in UI.
I have the feeling that this renaming was not mandatory ?
bundles/org.openhab.binding.systeminfo/src/main/resources/OH-INF/thing/channels.xml
Show resolved
Hide resolved
bundles/org.openhab.binding.systeminfo/src/main/resources/OH-INF/thing/channels.xml
Show resolved
Hide resolved
bundles/org.openhab.binding.systeminfo/src/main/resources/OH-INF/thing/channels.xml
Show resolved
Hide resolved
At my current review step, I am still not sure to understand why you need to create dynamically different thing types. |
"Addition of a process channel group for the current process that is running OH. This makes monitoring the OH process easier, as the PID would change with a restart." I'm interested in this piece above. Have a recently posted to understand how to get the current binding to work as such w/o anybody replying. https://community.openhab.org/t/oh-3-2-systeminfo-binding-process-pi4/140406 Best, Jay |
It was my understanding you can add channels dynamically, but not channel groups. There are no methods for that. One needs to create a new thing type. If I would create the same thing type, I would run into a conflict, or cannot use the static definition at all anymore. I would be very happy to be proven wrong about this. I believe there are very few bindings creating channel groups (from the top of my head: mqtt). |
It looks like you are right. I don't know why we have this restriction in the core framework. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review of changes in the thing handler
...teminfo/src/main/java/org/openhab/binding/systeminfo/internal/handler/SysteminfoHandler.java
Outdated
Show resolved
Hide resolved
groupChannelsByPriority(); | ||
scheduleUpdates(); | ||
updateStatus(ThingStatus.ONLINE); | ||
if (!addDynamicChannels()) { // If there are new channel groups, the thing will get recreated with a new |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like addDynamicChannels
can return true without calling changeThingType
. I have the feeling this case is not covered here ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, I missed that. I don't think it can happen, as the computer thing type is the default one from the xml definition, but I added a thing status update to cope with it if it would.
End of review. |
This pull request has been mentioned on openHAB Community. There might be relevant details there: https://community.openhab.org/t/oh-3-2-systeminfo-binding-process-pi4/140406/2 |
@mherwege : any chance you update the default translations, fix the typo and answer to the remaining question before Sunday? |
Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
@lolodomo I did the adjustments. Thank you for the review. |
} else { | ||
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.HANDLER_INITIALIZING_ERROR, | ||
"@text/offline.cannot-initialize"); | ||
return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you return false, this will trigger the additional code in initialize
that finally sets the status to ONLINE.
So either you have to return true there or you return false but do not set the status to OFFLINE there.
Something looks not coherent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lolodomo Indeed, didn't think it through well enough. I think the new commit should fix that. Not setting the status here would force me to set it in the initialize method, and I don't know in initialize if the handler is being recreated. It shouldn't set it if it is being recreated.
Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you
* Dynamic channels * Status messages i8n * Format fix * Cache process load values * Restore channel configs * Fix test * Stabilize tests * Fix CpuLoad1-5-15 update * Fix test bndrun * String equals cleanup * Fix potential null pointer in test Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
This pull request has been mentioned on openHAB Community. There might be relevant details there: https://community.openhab.org/t/openhab-3-4-milestone-discussion/138093/98 |
@mherwege : could you please have a look to the above community topic, it looks like your PR broke the binding... for at least one user. |
@lolodomo First analysis hints it may be linked to a file based thing definition. I don’t immediately see a way to fix that, and I am short in time at the moment to further analyse. I will do so later. Would you know if there is any way to detect if the definition was file based? If so, I could disable dynamic channels if one uses file thing definitions. |
* Dynamic channels * Status messages i8n * Format fix * Cache process load values * Restore channel configs * Fix test * Stabilize tests * Fix CpuLoad1-5-15 update * Fix test bndrun * String equals cleanup * Fix potential null pointer in test Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
* Dynamic channels * Status messages i8n * Format fix * Cache process load values * Restore channel configs * Fix test * Stabilize tests * Fix CpuLoad1-5-15 update * Fix test bndrun * String equals cleanup * Fix potential null pointer in test Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
* Dynamic channels * Status messages i8n * Format fix * Cache process load values * Restore channel configs * Fix test * Stabilize tests * Fix CpuLoad1-5-15 update * Fix test bndrun * String equals cleanup * Fix potential null pointer in test Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
This PR enhances the systeminfo binding to expose all devices on the system when multiple devices of the same type exist. So far, the binding only exposed the first of such devices.